package com.khaliil.kkadmin.demo.sse;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@Slf4j
public class SpringMvcSseService {
    public SseEmitter createSseEmitter() {
        SseEmitter sseEmitter = new SseEmitter();
        sseEmitter.onCompletion(() -> System.out.println("completed!"));
        sseEmitter.onTimeout(() -> System.out.println("timeout!"));
        sseEmitter.onError(e -> System.out.println(e.getMessage()));
        return sseEmitter;
    }

}
